package com.foodchain.controller;

import com.foodchain.entity.UserPointsConsume;
import com.foodchain.entity.UserPointsGain;
import com.foodchain.service.UserPointsGainService;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @ClassName UserPointsGainController
 * @Description TODO
 * @Author duyuanyuan
 * @Date 2019/3/27 13:56
 * @Version 1.0
 **/
@RequestMapping("/userIntegralRecord")
@Controller
public class UserPointsGainController extends BaseController {

    @Resource
    private UserPointsGainService service;

    /*
     * 功能描述:查询用户积分获取记录
     * @param:  * @param page
     * @param size
     * @param userId
     * @return: java.lang.String
     * @auther: duyuanyuan
     * @date: 2019/3/27 15:03
     */
    @RequestMapping("/userGain")
    @ResponseBody
    public String userGain(@RequestParam(value = "page", defaultValue = "0") Integer page,
                           @RequestParam(value = "size", defaultValue = "10") Integer size,String  userId){
        Page<UserPointsGain>  data = service.findGainList(page,size,userId);
        return JsonCode(0,"success",data);
    }

    /*
     * 功能描述:查询用户积分消耗记录
     * @param:  * @param page
     * @param size
     * @param userId
     * @return: java.lang.String
     * @auther: duyuanyuan
     * @date: 2019/3/27 15:04
     */
    @RequestMapping("/userConsume")
    @ResponseBody
    public String userConsume(@RequestParam(value = "page", defaultValue = "0") Integer page,
                           @RequestParam(value = "size", defaultValue = "10") Integer size,String  userId){
        Page<UserPointsConsume>  data = service.findConsumeList(page,size,userId);
        return JsonCode(0,"success",data);
    }


}
